package com.gitee.dengmin.tenant.config;

import com.gitee.dengmin.tenant.interceptor.RequestDomainInterceptor;
import com.gitee.dengmin.tenant.interceptor.TenantInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class SystemConfiguration extends WebMvcConfigurationSupport {

    @Bean
    public RequestDomainInterceptor requestDomainInterceptor(){
        return new RequestDomainInterceptor();
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
        registry.addInterceptor(requestDomainInterceptor());
    }

    @Bean
    public TenantInterceptor tenantInterceptor(){
        return new TenantInterceptor();
    }

}
